﻿<!-- "script/apps/Aries/Creator/Game/Areas/WorldFramePage.html" -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
</head>
<body>
    <pe:mcml>
<script refresh="false" type="text/npl" src="WorldFramePage.lua"><![CDATA[
NPL.load("(gl)script/apps/Aries/Creator/Game/Areas/WorldUploadPage.lua");
WorldUploadPage = commonlib.gettable("MyCompany.Aries.Creator.Game.Desktop.WorldUploadPage");
WorldUploadPage.OnInit()
GameLogic = commonlib.gettable("MyCompany.Aries.Game.GameLogic")
WorldFramePage = commonlib.gettable("MyCompany.Aries.Creator.Game.Desktop.WorldFramePage");
WorldFramePage.OnInit();

function ClosePage()
    Page:CloseWindow();
end

function GetCategoryButtons()
    return WorldFramePage.category_ds;
end

function OnChangeCategory(index)
    WorldFramePage.OnChangeCategory(index);
end

function OnSave()
    GameLogic.QuickSave();
end

function OnClickCreatePackage()
    GameLogic.SaveAll(false);
    WorldUploadPage.OnGeneratePackage();
end

function OnClickOpenPackageDir()
    Map3DSystem.App.Commands.Call("File.WinExplorer", {filepath = ParaWorld.GetWorldDirectory():gsub("[^/\\]+[/\\]$", ""), silentmode=true});
end

function GetPkgFileName()
    local filename = ParaWorld.GetWorldDirectory():match("([^/\\]+)[/\\]$");
    return format("%s.zip文件", commonlib.Encoding.DefaultToUtf8(filename));
end

local RecordGsid = WorldUploadPage.RecordGsid
local save_records = WorldUploadPage.LoadRecordData();

function DsCreativeSpaceWorlds(index)
    if(not index) then
        return #save_records;
    else
        return  save_records[index];
    end
end

function OnPurchaseSaveSlot()
    _guihelper.MessageBox("你尚未开启这个存档槽. 每购买一个会员物品, 可永久获得一个存档槽.", function(res)
        if(res) then
            System.App.Commands.GetCommand("Profile.Aries.PurchaseItemWnd"):Call({gsid = WorldUploadPage.ExtendedSlotCountGsid});
        end
    end);
end
    
function OnSaveToSlot(name, mcmlNode)
    WorldUploadPage.ClickOncePublish(name);
end

function OnClickShare(name, mcmlNode)
    NPL.load("(gl)script/apps/Aries/Creator/Game/GameMarket/ShareWorldToWeb.lua");
    local ShareWorldToWeb = commonlib.gettable("MyCompany.Aries.Creator.Game.Desktop.ShareWorldToWeb");
    ShareWorldToWeb.ShowPage(nil, tonumber(name))
end

function Dummy()
end

]]></script>
<pe:container alignment="_fi" width="100%" height="100%" onclick="Dummy()" style="padding:10px;background:url(Texture/whitedot.png);background-color:#000000cc">
<div style="width:220px;">
<pe:repeat DataSource="<%=GetCategoryButtons()%>">
    <pe:repeatitem style="float:left;">
        <pe:if condition='<%=WorldFramePage.category_index == Eval("index") %>' >
            <input type="button" value='<%=Eval("text")%>' name='<%=Eval("index")%>' onclick="OnChangeCategory" style="font-weight:bold;margin-right:8px;margin-top:8px;margin-bottom:0px;color:#33ff33;font-size:14px;height:32px;background:url(Texture/whitedot.png);background-color:#888888cc" />
        </pe:if>
        <pe:if condition='<%=WorldFramePage.category_index ~= Eval("index") %>' >
            <input type="button" value='<%=Eval("text")%>' name='<%=Eval("index")%>' onclick="OnChangeCategory" style="margin-right:8px;margin-top:8px;margin-bottom:0px;color:#ffffff;font-size:14px;height:32px;background:url(Texture/whitedot.png);background-color:#888888cc" />
        </pe:if>
    </pe:repeatitem>
</pe:repeat>
</div>
<div style="margin-left:-5px;margin-top:10px;padding-left:5px;width:225px;height:400px;color:#cccccc">
    <pe:if condition='<%=WorldFramePage.category_index == 1%>'>
        <pe:if condition='<%=GameLogic.IsReadOnly()%>'>
            只读世界, 无法保存
        </pe:if>
        <pe:if condition='<%=not GameLogic.IsReadOnly()%>'>
            <div>世界只保存在了您的个人电脑上</div>
            <input type="button" value="本地保存" tooltip="快捷键:Ctrl+S" class="mc_big_button" style="margin-top:5px;min-width:110px;" onclick="OnSave"/><br />

            <div style="margin-top:30px;">
                可用服务器存档槽:<pe:slot style="float:left;" type="count" gsid='<%=WorldUploadPage.RecordGsid %>'></pe:slot>
                <div><pe:label name="progress" style="float:left;margin-left:20spx;height:23px;">点击你要覆盖的存档. </pe:label></div>
            </div>
            <div style="width:300px;">
                <pe:gridview name="gvwTableCSWorlds" CellPadding="0"  AllowPaging="true" DefaultNodeHeight = "35" pagesize="6"
                    DataSource='<%=DsCreativeSpaceWorlds%>' >
	                <Columns>
                        <pe:if condition='<%=Eval("type") ~= "empty" %>'>
                            <input type="button" name='<%=Eval("index")%>' tooltip='<%=format("存档日期:%s", Eval("date") or "") %>' class="mc_big_button"  onclick="OnSaveToSlot" value='<%=format("存档%d: [%s] 版本:%d",  Eval("index"), Eval("worldname") or "空", Eval("revision") or 0)%>' style="margin-top:5px;width:200px;font-size:14px;font-weight:bold;height:32px;"/>
                            <pe:if condition='<%=Eval("revision") ~= 0 %>'>
                                <input type="button" name='<%=Eval("index")%>' value="分享" class="mc_big_button" tooltip="分享到互联网" style="margin-top:5px;margin-left:3px;width:40px;height:30px;" onclick="OnClickShare" />
                            </pe:if>
                        </pe:if>
                        <pe:if condition='<%=Eval("type") == "empty" %>'>
                            <input type="button" onclick="OnPurchaseSaveSlot" value="空存档 [未开启]" class="mc_grey_button" style="margin-top:5px;width:200px;font-size:14px;font-weight:bold;height:30px;"/>
                        </pe:if>
	                </Columns>
                    <FetchingDataTemplate>
		                <div style="margin:10px;">正在获取信息...</div>
	                </FetchingDataTemplate>
                    <PagerSettings Position="Bottom" />
                    <PagerTemplate AutoHidePager="false" style="margin-left:70px;">
			            <form>
				            <input type="button" name="pre" invisibleondisabled="false" style="width:16px;height:16px;background:url(Texture/Aries/Creator/Desktop/Inventory_32bits.png#294 486 16 16)"/>
					            <input type="button" name="page" style="width:50px;height:16px;margin-top:1px;font-size:12px;color:#ffffff;background:;" /> 
				            <input type="button" name="next" invisibleondisabled="false" style="width:16px;height:16px;background:url(Texture/Aries/Creator/Desktop/Inventory_32bits.png#294 470 16 16)" />
	                    </form>
		            </PagerTemplate>
                </pe:gridview>
            </div>
        </pe:if>
    </pe:if>
    <pe:if condition='<%=WorldFramePage.category_index == 2%>'>
        <div style="margin-top:5px;padding:10px;margin-left:0px;" class="mc_border" width="100%">
            <div style="font-weight:bold">第一步: 将世界打包成zip文件 </div>
            <div style="float:left;margin-left:5px;width:270px;">
                <div style="margin-top:5px;">
                    <div style="float:left;width:70px;text-align:right">领地名称:</div><input name="world_name" style="width:120px;height:22px;"/>
                </div>
                <div>
                    <div style="float:left;width:70px;text-align:right">世界路径:</div>
                    <a onclick="MyCompany.Aries.Creator.SaveWorldPage.OnOpenWorldDir" tooltip="点击打开文件夹">
                        <img style="margin-right:3px;margin-top:2px;background:url(Texture/3DMapSystem/common/ViewFiles.png);width:16px;height:16px;"/>
                        <label name="worldpath" style="color:#cccccc;"/>
                    </a>
                </div>
                <input type="button" class="mc_big_button" onclick="OnClickCreatePackage" style="margin-top:5px;width:120px;height:32px;font-weight:bold;" value="开始打包..."/><br />
                <label name="result" style="color:#303030;height:30px;"></label>
            </div>
            <div style="float:left;margin-top:-22px;margin-left:5px;">
                <div style="margin-top:1px;font-weight:bold;color:#aaaaaa">
                    世界预览图: 
                    <input type="button" onclick="MyCompany.Aries.Creator.SaveWorldPage.TakeWorldImage" name="takesnapshot" style="font-size:12px;margin-top:-2px;min-width:60px;" class="mc_small_button" value="截图"/>
                </div>
                <div style="padding:2px;background:url(Texture/Aries/common/picbg16_32bits.png#0 0 16 16: 3 3 3 3);">
                    <img name="WorldImage" zorder="1" width="180" height="110"/>
                </div>
            </div>
        </div>
        <div style="margin-top:5px;padding:10px;margin-left:0px;" class="mc_border" width="100%">
            <div style="font-weight:bold">第二步: 上传分享 </div>
            <div style="float:left;margin-left:10px;margin-top:5px;">
                您可以将<a tooltip="点击打开所在目录" onclick="OnClickOpenPackageDir"><%=GetPkgFileName()%></a>上传到
                <pe:if condition='<%=System.options.version == "kids" %>'>
                <a href="http://tieba.baidu.com/f?kw=%C4%A7%B7%A8%B9%FE%C6%E6">魔法哈奇百度贴吧</a>方便大家交流
                </pe:if>
                <pe:if condition='<%=System.options.version == "teen" %>'>
                    官方论坛
                </pe:if>
            </div>
        </div>
        <div style="margin-top:5px;padding:10px;margin-left:0px;" class="mc_border" width="100%">
            <div style="font-weight:bold">第三步: 推广你的世界</div>
            <div style="float:left;margin-left:10px;margin-top:5px;">
                您可以通过全区大喇叭, 邀请好友下载和参观你的世界<br />
                <pe:if condition='<%=System.options.version == "kids" %>'>
                您也可以将自己的世界拍摄成视频, 上传到<a href="http://www.aipai.com/game_gameid-47617.html">魔法哈奇爱拍社区</a><br />
                您也可以在魔法哈奇贴吧中用图片直播自己创造世界的过程.
                </pe:if>
            </div>
        </div>
    </pe:if>
</div>
</pe:container>
</pe:mcml>
</body>
</html>

